package com.glory.nicleanrpt

import com.ivan.utils.PathUtil

/**
 * @Program: njcleanrpt
 * @Description: 纳期
 * @Author: ivan
 */
class NanningPeriodController {

    def dynamicQueryService

    def nanningPeriod() {
        request.setCharacterEncoding("UTF-8")
        response.setContentType("text/html;charset=UTF-8")
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 100
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def pageSizeList = [10, 20, 50, 100]
        def report_011 = []
        def tableHeadList = []
        def totalCount = 0
        // 加急状态
        params.SYS_QUERY_NAME = 'urgentStateList'
        def urgentStateList = dynamicQueryService.queryForList(params)
        // 纳期状态
        params.SYS_QUERY_NAME = 'naQiStateList'
        def naQiStateList = dynamicQueryService.queryForList(params)
        // 发货状态
        params.SYS_QUERY_NAME = 'sendGoodsStateList'
        def sendGoodsStateList = dynamicQueryService.queryForList(params)
        def sysQueryName
        def sysQueryPath = PathUtil.getPath(this, request)
        if ('Excel'.equals(params.EXPORT_CONTENT_NAME)) {
            params.SYS_QUERY_NAME = 'nanningPeriodList'
            report_011 = dynamicQueryService.queryForList(params)
            if (report_011.size() > 0) {
                tableHeadList = report_011[0].keySet()
            }
            sysQueryName = params.SYS_QUERY_NAME
            params.SYS_QUERY_NAME = 'nanningPeriodCount'
            totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT
        }
        [
                pageCurrent       : pageCurrent,
                pageSize          : pageSize,
                pageSizeList      : pageSizeList,
                startno           : params.startno ?: '',
                endno             : params.endno ?: '',
                customName        : params.customName ?: '',
                deviceName        : params.deviceName ?: '',
                partName          : params.partName ?: '',
                srStartTime       : params.srStartTime ?: '',
                srEndTime         : params.srEndTime ?: '',
                fhStartTime       : params.fhStartTime ?: '',
                fhEndTime         : params.fhEndTime ?: '',
                urgentState       : params.urgentState ?: '',
                naQiState         : params.naQiState ?: '',
                sendGoodsState    : params.sendGoodsState ?: '',
                report_011        : report_011,
                totalCount        : totalCount,
                tableHeadList     : tableHeadList,
                urgentStateList   : urgentStateList,
                naQiStateList     : naQiStateList,
                sendGoodsStateList: sendGoodsStateList,
                SYS_QUERY_PATH    : sysQueryPath,
                SYS_QUERY_NAME    : sysQueryName
        ]
    }
}